<template>
  <div>
    <div>
      <el-radio-group v-model="data.type" @change="actionTypeChange">
        <el-radio v-if="actions.indexOf('device') >= 0" :label="'device'"
          >设备控制</el-radio
        >
        <el-radio v-if="actions.indexOf('alarm') >= 0" :label="'alarm'"
          >告警消息</el-radio
        >
        <el-radio v-if="actions.indexOf('scene') >= 0" :label="'scene'"
          >场景控制</el-radio
        >
        <el-radio v-if="actions.indexOf('http') >= 0" :label="'http'"
          >http推送</el-radio
        >
      </el-radio-group>
    </div>
    <DeviceAction :config="data" v-if="data.type == 'device'"></DeviceAction>
    <HttpAction :config="data" v-if="data.type == 'http'"></HttpAction>
  </div>
</template>

<script>
import DeviceAction from "./DeviceAction.vue";
import HttpAction from "./HttpAction.vue";
export default {
  name: "Action",
  props: {
    data: {
      type: Object,
      default: () => {
        return {
          type: "",
          services: [{}],
        };
      },
    },
    actions: {
      type: String,
      default: () => {
        return "device";
      },
    },
  },
  data() {
    return {};
  },
  components: {
    DeviceAction,
    HttpAction,
  },
  created() {},
  methods: {
    actionTypeChange() {
      if (this.data.services.length == 0) {
        if (this.data.type == "http") {
          this.data.services = [
            {
              url: "",
              script: `this.translate=function(msg){
              
}`,
            },
          ];
        }
      }
    },
  },
};
</script>

<style>
</style>
